﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using WoChu.RfClient.Entity;
using System.Data;

namespace WoChu.RfClient.Duty
{
    public class OffShelvesOrderUIRule:IOffShelvesOrder
    {
        private static OffShelvesOrderUIRule _NewInstance = new OffShelvesOrderUIRule();

        public static OffShelvesOrderUIRule NewInstance
        {
            get
            {
                if (_NewInstance == null)
                {
                    _NewInstance = new OffShelvesOrderUIRule();
                }

                return _NewInstance;
            } 
        }


        #region IOffShelvesOrder 成员 

        public ResultModel<List<OffShelvesInfo>> GetOffCellNo(string userID)
        {
            try
            {
                var _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IOffShelvesOrder>.NewInstance.InvokeWebMethod<ResultModel<List<OffShelvesInfo>>>("GetOffCellNo", new object[] { userID });
                if (_result == null)
                    return new ResultModel<List<OffShelvesInfo>>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<List<OffShelvesInfo>>().GetInstance();
            }
        }

        public ResultModel<List<OffShelvesInfo>> GetOffShelvesInfo(string cellNo, string batchNo, string userID, DateTime offShelvesDate)
        {
            try
            {
                ResultModel<List<OffShelvesInfo>> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IOffShelvesOrder>.NewInstance.InvokeWebMethod < ResultModel<List<OffShelvesInfo>>>("GetOffShelvesInfo", new object[] { cellNo, batchNo, userID, offShelvesDate });
                if (_result == null)
                    return new ResultModel<List<OffShelvesInfo>>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<List<OffShelvesInfo>>().GetInstance();
            }
           
        }

        public ResultModel<bool> SetOffShelvesState(string setType, List<OffShelvesInfo> lstOffShelves)
        {
            try
            {
                ResultModel<bool> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IOffShelvesOrder>.NewInstance.InvokeWebMethod<List<OffShelvesInfo>, ResultModel<bool>>("SetOffShelvesState", new object[] { setType }, lstOffShelves);
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<bool>().GetInstance();
            }
           
        }

        public ResultModel<bool> SetOffShelves(string userID, List<OffShelvesInfo> lstOffShelves)
        { 
            try
            { 
                ResultModel<bool> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IOffShelvesOrder>.NewInstance.InvokeWebMethod<List<OffShelvesInfo>, ResultModel<bool>>("SetOffShelves", new object[] { userID }, lstOffShelves);
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;
 
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<bool>().GetInstance();
            }
        }

        #endregion
 
    }
}
